/// 响应主体内容
import 'SysMenuVo.dart';

class BackendLoginResponseDto {
  /// 用户ID
  final int? userId;
  /// 系统代码：1-客户端 2-平台端 3-核销代理端 4-财务代理端
  final int? systemCode;
  /// 用户名
  final String? userName;
  /// token
  final String? token;
  /// 是否主账号：1-是，0-否
  final int? mainUser;
  /// 菜单列表
  final List<SysMenuVo>? menuList;
  /// 客服的报价权限，1-有，0-无，平台账号登录时忽略该参数
  final int? quotePermission;

  BackendLoginResponseDto({
    this.userId,
    this.systemCode,
    this.userName,
    this.token,
    this.mainUser,
    this.menuList,
    this.quotePermission,
  });

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (userId != null) data['userId'] = userId;
    if (systemCode != null) data['systemCode'] = systemCode;
    if (userName != null) data['userName'] = userName;
    if (token != null) data['token'] = token;
    if (mainUser != null) data['mainUser'] = mainUser;
    if (menuList != null) data['menuList'] = menuList!.map((e) => e.toJson()).toList();
    if (quotePermission != null) data['quotePermission'] = quotePermission;
    return data;
  }

  factory BackendLoginResponseDto.fromJson(Map<String, dynamic> json) {
    return BackendLoginResponseDto(
      userId: json['userId'],
      systemCode: json['systemCode'],
      userName: json['userName'],
      token: json['token'],
      mainUser: json['mainUser'],
      menuList: json['menuList'] != null ? List<SysMenuVo>.from(json['menuList'].map((x) => SysMenuVo.fromJson(x))) : [],
      quotePermission: json['quotePermission'],
    );
  }
}